package com.qfedu.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qfedu.dao.CommentMapper;
import com.qfedu.pojo.entity.Comment;
import com.qfedu.pojo.resp.BaseResp;
import com.qfedu.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    CommentMapper commentMapper;

    @Override
    public BaseResp findAll(Integer page, Integer size) {
        //在查询数据之前先来设置分页数据
        PageHelper.startPage(page,size);
        List<Comment> all = commentMapper.findAll();
        System.out.println("all = " + all);
        PageInfo<Comment> commentPageInfo = new PageInfo<>(all);
        return new BaseResp(1,"success",commentPageInfo.getList(),commentPageInfo.getTotal());
    }

}
